<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Claude Code 命令大全 - 10分钟掌握所有核心命令 | Ctok</title>
    <meta name="description" content="10分钟掌握所有 Claude Code 核心命令，从初学者到专家级使用技巧">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
            line-height: 1.6;
            color: #333;
            background: #f8fafc;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }
        
        /* Header */
        .header {
            background: #fff;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            position: sticky;
            top: 0;
            z-index: 100;
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 0;
        }
        
        .logo {
            font-size: 24px;
            font-weight: bold;
            color: #2563eb;
            text-decoration: none;
        }
        
        .nav {
            display: flex;
            list-style: none;
            gap: 30px;
        }
        
        .nav a {
            text-decoration: none;
            color: #64748b;
            font-weight: 500;
            transition: color 0.3s;
        }
        
        .nav a:hover {
            color: #2563eb;
        }
        
        /* Article Layout */
        .article-container {
            display: grid;
            grid-template-columns: 250px 1fr;
            gap: 40px;
            padding: 40px 0;
            max-width: 1200px;
            margin: 0 auto;
        }
        
        /* Table of Contents */
        .toc {
            background: #fff;
            border-radius: 12px;
            padding: 30px;
            height: fit-content;
            position: sticky;
            top: 100px;
            border: 1px solid #e2e8f0;
        }
        
        .toc h3 {
            color: #1e293b;
            margin-bottom: 20px;
            font-size: 1.2rem;
        }
        
        .toc ul {
            list-style: none;
        }
        
        .toc ul ul {
            margin-left: 15px;
            margin-top: 5px;
        }
        
        .toc li {
            margin-bottom: 8px;
        }
        
        .toc a {
            color: #64748b;
            text-decoration: none;
            font-size: 0.95rem;
            transition: color 0.3s;
        }
        
        .toc a:hover {
            color: #2563eb;
        }
        
        /* Main Content */
        .main-content {
            background: #fff;
            border-radius: 12px;
            padding: 40px;
            border: 1px solid #e2e8f0;
        }
        
        .article-header {
            margin-bottom: 40px;
            padding-bottom: 30px;
            border-bottom: 2px solid #e2e8f0;
        }
        
        .article-header h1 {
            font-size: 2.5rem;
            color: #1e293b;
            margin-bottom: 15px;
            font-weight: 700;
        }
        
        .article-meta {
            color: #64748b;
            font-size: 1rem;
        }
        
        .content h2 {
            color: #1e293b;
            font-size: 1.8rem;
            margin: 40px 0 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e2e8f0;
        }
        
        .content h3 {
            color: #374151;
            font-size: 1.4rem;
            margin: 30px 0 15px;
        }
        
        .content h4 {
            color: #4b5563;
            font-size: 1.2rem;
            margin: 25px 0 10px;
        }
        
        .content p {
            margin-bottom: 20px;
            line-height: 1.7;
            color: #374151;
        }
        
        .content ul, .content ol {
            margin: 20px 0;
            padding-left: 30px;
        }
        
        .content li {
            margin-bottom: 8px;
            line-height: 1.6;
        }
        
        .content code {
            background: #f1f5f9;
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
            font-size: 0.9em;
            color: #e11d48;
        }
        
        .content pre {
            background: #1e293b;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 8px;
            overflow-x: auto;
            margin: 20px 0;
        }
        
        .content pre code {
            background: none;
            padding: 0;
            color: inherit;
        }
        
        .command-card {
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
        }
        
        .command-card h4 {
            color: #2563eb;
            margin-bottom: 10px;
            font-size: 1.1rem;
        }
        
        .command-card .command {
            background: #1e293b;
            color: #e2e8f0;
            padding: 10px;
            border-radius: 4px;
            font-family: monospace;
            margin: 10px 0;
        }
        
        .command-card .description {
            color: #64748b;
            font-size: 0.95rem;
            line-height: 1.5;
        }
        
        .highlight-box {
            background: #dbeafe;
            border-left: 4px solid #2563eb;
            padding: 20px;
            margin: 20px 0;
            border-radius: 4px;
        }
        
        .warning-box {
            background: #fef3c7;
            border-left: 4px solid #f59e0b;
            padding: 20px;
            margin: 20px 0;
            border-radius: 4px;
        }
        
        .success-box {
            background: #dcfce7;
            border-left: 4px solid #16a34a;
            padding: 20px;
            margin: 20px 0;
            border-radius: 4px;
        }
        
        /* Responsive */
        @media (max-width: 1024px) {
            .article-container {
                grid-template-columns: 1fr;
                gap: 20px;
            }
            
            .toc {
                position: static;
                order: -1;
            }
        }
        
        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                gap: 20px;
            }
            
            .nav {
                gap: 15px;
                flex-wrap: wrap;
                justify-content: center;
            }
            
            .main-content {
                padding: 25px;
            }
            
            .article-header h1 {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <header class="header">
        <div class="container">
            <div class="header-content">
                <a href="index.html" class="logo">Ctok</a>
                <nav>
                    <ul class="nav">
                        <li><a href="index.html">首页</a></li>
                        <li><a href="claude-code-complete-guide.html">使用指南</a></li>
                        <li><a href="claude-code-carpool.html">拼车服务</a></li>
                        <li><a href="en/">English</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </header>

    <div class="container">
        <div class="article-container">
            <aside class="toc">
                <h3>目录</h3>
                <ul>
                    <li><a href="#basic-commands">基础命令</a></li>
                    <li><a href="#file-operations">文件操作</a></li>
                    <li><a href="#project-management">项目管理</a></li>
                    <li><a href="#code-generation">代码生成</a></li>
                    <li><a href="#analysis-review">分析与审查</a></li>
                    <li><a href="#mcp-commands">MCP 命令</a></li>
                    <li><a href="#configuration">配置命令</a></li>
                    <li><a href="#advanced-usage">高级用法</a></li>
                    <li><a href="#shortcuts">快捷键</a></li>
                </ul>
            </aside>

            <main class="main-content">
                <div class="article-header">
                    <h1>Claude Code 命令大全</h1>
                    <div class="article-meta">
                        10分钟掌握所有核心命令 | 最后更新：2024年1月
                    </div>
                </div>

                <div class="content">
                    <div class="highlight-box">
                        <p><strong>⚡ 快速上手：</strong> 本指南涵盖了所有 Claude Code 核心命令，按功能分类整理，每个命令都有详细说明和使用示例。建议收藏备用！</p>
                    </div>

                    <h2 id="basic-commands">基础命令</h2>
                    
                    <div class="command-card">
                        <h4>版本信息</h4>
                        <div class="command">claude-code --version</div>
                        <div class="description">显示 Claude Code CLI 的版本信息</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>帮助信息</h4>
                        <div class="command">claude-code --help</div>
                        <div class="description">显示所有可用命令的帮助信息</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>登录账户</h4>
                        <div class="command">claude-code auth login</div>
                        <div class="description">登录到你的 Claude 账户</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>退出登录</h4>
                        <div class="command">claude-code auth logout</div>
                        <div class="description">退出当前登录的账户</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>检查状态</h4>
                        <div class="command">claude-code status</div>
                        <div class="description">显示当前项目和账户状态</div>
                    </div>

                    <h2 id="file-operations">文件操作</h2>
                    
                    <div class="command-card">
                        <h4>创建文件</h4>
                        <div class="command">claude-code create --file &lt;filename&gt; --prompt "&lt;描述&gt;"</div>
                        <div class="description">根据描述创建新文件</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>编辑文件</h4>
                        <div class="command">claude-code edit --file &lt;filename&gt; --prompt "&lt;修改要求&gt;"</div>
                        <div class="description">根据要求修改指定文件</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>读取文件</h4>
                        <div class="command">claude-code read --file &lt;filename&gt;</div>
                        <div class="description">读取并显示文件内容</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>搜索文件</h4>
                        <div class="command">claude-code search --pattern "&lt;搜索内容&gt;" --path &lt;目录&gt;</div>
                        <div class="description">在指定目录中搜索匹配的内容</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>批量处理</h4>
                        <div class="command">claude-code batch --files "*.py" --prompt "&lt;批量操作&gt;"</div>
                        <div class="description">对匹配的文件执行批量操作</div>
                    </div>

                    <h2 id="project-management">项目管理</h2>
                    
                    <div class="command-card">
                        <h4>初始化项目</h4>
                        <div class="command">claude-code init</div>
                        <div class="description">在当前目录初始化 Claude Code 项目</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>项目分析</h4>
                        <div class="command">claude-code analyze</div>
                        <div class="description">分析整个项目的结构和代码质量</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>项目构建</h4>
                        <div class="command">claude-code build</div>
                        <div class="description">构建当前项目</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>运行测试</h4>
                        <div class="command">claude-code test</div>
                        <div class="description">运行项目的所有测试</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>项目清理</h4>
                        <div class="command">claude-code clean</div>
                        <div class="description">清理项目中的临时文件和缓存</div>
                    </div>

                    <h2 id="code-generation">代码生成</h2>
                    
                    <div class="command-card">
                        <h4>生成代码</h4>
                        <div class="command">claude-code generate --prompt "&lt;需求描述&gt;" --language &lt;语言&gt;</div>
                        <div class="description">根据需求描述生成指定语言的代码</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>生成测试</h4>
                        <div class="command">claude-code test --file &lt;filename&gt; --framework &lt;测试框架&gt;</div>
                        <div class="description">为指定文件生成测试代码</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>生成文档</h4>
                        <div class="command">claude-code doc --file &lt;filename&gt;</div>
                        <div class="description">为代码生成文档注释</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>代码补全</h4>
                        <div class="command">claude-code complete --file &lt;filename&gt; --line &lt;行号&gt;</div>
                        <div class="description">在指定位置进行智能代码补全</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>模板生成</h4>
                        <div class="command">claude-code template --type &lt;模板类型&gt; --name &lt;项目名&gt;</div>
                        <div class="description">使用预定义模板创建项目结构</div>
                    </div>

                    <h2 id="analysis-review">分析与审查</h2>
                    
                    <div class="command-card">
                        <h4>代码审查</h4>
                        <div class="command">claude-code review --file &lt;filename&gt;</div>
                        <div class="description">对指定文件进行代码审查</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>安全检查</h4>
                        <div class="command">claude-code security --path &lt;路径&gt;</div>
                        <div class="description">检查代码中的安全漏洞</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>性能分析</h4>
                        <div class="command">claude-code performance --file &lt;filename&gt;</div>
                        <div class="description">分析代码性能并提出优化建议</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>代码解释</h4>
                        <div class="command">claude-code explain --file &lt;filename&gt; --lines &lt;开始行&gt;-&lt;结束行&gt;</div>
                        <div class="description">解释指定行范围的代码功能</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>重构建议</h4>
                        <div class="command">claude-code refactor --file &lt;filename&gt; --focus "&lt;重构重点&gt;"</div>
                        <div class="description">提供代码重构建议</div>
                    </div>

                    <h2 id="mcp-commands">MCP 命令</h2>
                    
                    <div class="command-card">
                        <h4>安装 MCP 服务器</h4>
                        <div class="command">claude-code mcp install &lt;服务器名&gt;</div>
                        <div class="description">安装指定的 MCP 服务器</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>MCP 状态</h4>
                        <div class="command">claude-code mcp status</div>
                        <div class="description">显示所有 MCP 服务器的运行状态</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>启动 MCP 服务器</h4>
                        <div class="command">claude-code mcp start &lt;服务器名&gt;</div>
                        <div class="description">启动指定的 MCP 服务器</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>停止 MCP 服务器</h4>
                        <div class="command">claude-code mcp stop &lt;服务器名&gt;</div>
                        <div class="description">停止指定的 MCP 服务器</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>MCP 日志</h4>
                        <div class="command">claude-code mcp logs &lt;服务器名&gt;</div>
                        <div class="description">查看 MCP 服务器的日志</div>
                    </div>

                    <h2 id="configuration">配置命令</h2>
                    
                    <div class="command-card">
                        <h4>查看配置</h4>
                        <div class="command">claude-code config list</div>
                        <div class="description">显示所有配置项</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>设置配置</h4>
                        <div class="command">claude-code config set &lt;键&gt; &lt;值&gt;</div>
                        <div class="description">设置配置项的值</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>获取配置</h4>
                        <div class="command">claude-code config get &lt;键&gt;</div>
                        <div class="description">获取指定配置项的值</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>重置配置</h4>
                        <div class="command">claude-code config reset</div>
                        <div class="description">重置所有配置为默认值</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>验证配置</h4>
                        <div class="command">claude-code config validate</div>
                        <div class="description">验证当前配置是否正确</div>
                    </div>

                    <h2 id="advanced-usage">高级用法</h2>
                    
                    <h3>管道操作</h3>
                    <p>Claude Code 支持与其他命令行工具组合使用：</p>
                    <pre><code># 对 Git 差异进行代码审查
git diff | claude-code review --stdin

# 分析日志文件
cat error.log | claude-code analyze --type logs

# 批量处理文件
find . -name "*.js" | xargs claude-code review</code></pre>
                    
                    <h3>环境变量</h3>
                    <p>常用环境变量设置：</p>
                    <pre><code># 设置 API 密钥
export CLAUDE_API_KEY="your-api-key"

# 设置默认模型
export CLAUDE_MODEL="claude-3-sonnet"

# 启用调试模式
export CLAUDE_DEBUG=true

# 设置输出格式
export CLAUDE_OUTPUT_FORMAT="json"</code></pre>
                    
                    <h3>配置文件示例</h3>
                    <p>项目级配置文件 <code>claude-config.json</code>：</p>
                    <pre><code>{
  "model": "claude-3-sonnet",
  "maxTokens": 4000,
  "temperature": 0.7,
  "filePatterns": {
    "include": ["src/**/*.py", "tests/**/*.py"],
    "exclude": ["**/__pycache__/**", "**/node_modules/**"]
  },
  "codeStyle": {
    "language": "python",
    "style": "pep8",
    "maxLineLength": 88
  },
  "mcp": {
    "servers": {
      "filesystem": {
        "command": "mcp-server-filesystem",
        "args": ["."]
      }
    }
  }
}</code></pre>

                    <h2 id="shortcuts">快捷键和别名</h2>
                    
                    <h3>常用别名</h3>
                    <p>为常用命令设置别名可以提高效率：</p>
                    <pre><code># 添加到 ~/.bashrc 或 ~/.zshrc
alias cc="claude-code"
alias ccr="claude-code review"
alias cce="claude-code edit"
alias ccc="claude-code create"
alias cca="claude-code analyze"</code></pre>
                    
                    <h3>快速操作</h3>
                    <div class="command-card">
                        <h4>快速审查当前文件</h4>
                        <div class="command">cc review $(pwd)/$(basename $(pwd)).py</div>
                        <div class="description">审查当前目录下与目录同名的 Python 文件</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>快速分析项目</h4>
                        <div class="command">cc analyze --output summary.md</div>
                        <div class="description">分析项目并将结果保存到 summary.md</div>
                    </div>
                    
                    <div class="command-card">
                        <h4>批量优化</h4>
                        <div class="command">cc batch --files "src/**/*.py" --prompt "optimize for performance"</div>
                        <div class="description">对所有 Python 源文件进行性能优化</div>
                    </div>

                    <div class="success-box">
                        <p><strong>🎉 完成学习！</strong> 恭喜你掌握了 Claude Code 的所有核心命令。现在你已经具备了高效使用 Claude Code 的基础知识。建议将本页面收藏，作为日常开发的参考手册。</p>
                    </div>
                    
                    <div class="highlight-box">
                        <p><strong>📖 延伸阅读：</strong> 
                        <br>• <a href="claude-code-complete-guide.html">完整使用指南</a> - 深入了解每个功能
                        <br>• <a href="claude-code-mcp-server-guide.html">MCP 服务器指南</a> - 扩展 Claude Code 功能
                        <br>• <a href="claude-code-carpool.html">拼车服务</a> - 经济实惠的使用方案</p>
                    </div>
                </div>
            </main>
        </div>
    </div>
</body>
</html>